import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		topListIds: [],
		nextId: ''
	},
	mutations: {
		// 这是干嘛的
		INIT_TOPLISTIDS(state, payload) {
			state.topListIds = payload
		},
		NEXT_ID(state, payload) {
			const index = state.topListIds.findIndex(item => item.id == payload)
			if (index != -1) {
				if (index == state.topListIds.length - 1) {
					state.nextId = 0
				} else {
					state.nextId = state.topListIds[index + 1].id
				}
			}
		}
	},

})
